package com.dl.code.controller;

import com.dl.code.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * 作者: DL代先生
 * 日期: 2021/5/29
 * 时间: 19:16
 * 内容: Shiro与springboot整合教程！
 * 描述:
 */
@Controller
@RequestMapping("user")
public class UserController {

    private UserService userService;
    public UserController(UserService userService) {
        this.userService = userService;
    }

    @RequestMapping("checkLogin")
    public String checkLogin(String userAccount,String password){
        userService.checkLogin(userAccount,password);
        return "index";
    }

    @RequestMapping("register")
    @ResponseBody
    public String register(String userAccount,String password){
        boolean register = userService.register(userAccount, password);
        if (register){
            System.out.println("注册成功");
        }else {
            System.out.println("注册失败");
        }
        return "success";
    }
}
